Fix flexible array buffer overflow
Origin: https://gitlab.freedesktop.org/spice/spice-common/commit/
bb15d4815ab586b4c4a20f4a565970a44824c42c
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2018-10873
Bug-Debian: https://bugs.debian.org/906316
This is kind of a DoS, possibly flexible array in the protocol
causes the network size check to be ignored due to integer overflows.
The size of flexible array is computed as (message_end - position),
then this size is added to the number of bytes before the array and
this number is used to check if we overflow initial message.
An example is:
message {
uint32 dummy[2];
uint8 data[] @end;
} LenMessage;
which generated this (simplified remove useless code) code:
{ /* data */
data__nelements = message_end - (start + 8);
data__nw_size = data__nelements;
}
nw_size = 8 + data__nw_size;
/* Check if message fits in reported side */
if (nw_size > (uintptr_t) (message_end - start)) {
return NULL;
}
Following code:
- data__nelements == message_end - (start + 8)
- data__nw_size == data__nelements == message_end - (start + 8)
- nw_size == 8 + data__nw_size == 8 + message_end - (start + 8) ==
8 + message_end - start - 8 == message_end -start
- the check for overflow is (nw_size > (message_end - start)) but
nw_size == message_end - start so the check is doing
((message_end - start) > (message_end - start)) which is always false.
If message_end - start < 8 then data__nelements (number of element
on the array above) computation generate an integer underflow that
later create a buffer overflow.
Add a check to make sure that the array starts before the message ends
to avoid the overflow.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
[Salvatore Bonaccorso: Drop generated diff from commit messages causing
problem when applying with quilt. Remove addition to testsuite]
Gbp-Pq: Name Fix-flexible-array-buffer-overflow.patch
debian_843471-clipboard_Fix_crash_by_handling_error
commit
03c016bea939ee4a26e90d80fa1012a993a8ea47
Author: Victor Toso <me@victortoso.com>
Origin: upstream, https://cgit.freedesktop.org/spice/spice-gtk/commit/?id=
03c016bea939ee4a26e90d80fa1012a993a8ea47
Bug-Debian: https://bugs.debian.org/843471
Date: Fri Oct 14 18:12:01 2016 +0200
clipboard: Fix crash by handling error
As manual states below, text could be NULL for different reasons and
we should handle that. I've included a debug message to help
identifying possible regressions from wayland's clipboard.
This crash is a regression from
7b0de6217670e0f668aff2949f
"The text parameter to callback will contain the resulting text if
the request succeeded, or NULL if it failed. This could happen for
various reasons, in particular if the clipboard was empty or if the
contents of the clipboard could not be converted into text form."
Resolves: rhbz#
1384676
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
Gbp-Pq: Name debian_843471-clipboard_Fix_crash_by_handling_error.patch